package com.sy.controller;

import com.sy.dto.JsonResult;
import com.sy.service.RankingListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * Description:
 * date: 2021/1/19 14:49
 * 与排行榜相关操作的控制层
 * @author:
 * @since JDK 1.8
 */
@RestController
public class RankingListController {
    @Autowired
    private RankingListService rankingListService;
    @Autowired(required = false)
    private HttpServletResponse res;

    /**
     * 获得博客周排行榜集合
     * @return
     */
    @RequestMapping("/weekRankingLists")
    public JsonResult getWeekRankingList(){
        JsonResult result = rankingListService.getWeekRankingList();
        res.setStatus(result.getCode());
        return result;
    }

    @RequestMapping("/userRankings/{userId}")
    public JsonResult getUserRankingInfo(@PathVariable("userId")Integer userId){
        JsonResult result = rankingListService.getUserRankingInfo(userId);
        res.setStatus(result.getCode());
        return result;
    }
}
